package com.bruce.learnrecycler.kotlin.model.shjt.alllines;

import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Bruce-Home on 2015/8/30.
 */
@Deprecated
public class LinePojo {
    public static class LineInternal {
        public String name;
        public String actual;

        public LineInternal(String name, String actual) {
            this.name = name;
            this.actual = actual;
        }
    }
    public List<LineInternal> lines = new ArrayList<>();

    private static LineInternal convert(Line line) {
        return new LineInternal(line.getName(), line.getActual());
    }

    public static LinePojo convert(LineXml lineXml) {
        LinePojo pojo = new LinePojo();
        for (Line line : lineXml.getLines()) {
            pojo.lines.add(convert(line));
        }
        return pojo;
    }

    public static void main(String[] args) {
        LinePojo pojo = new LinePojo();
        for (int i = 0; i < 10; i++) {
            LineInternal internal = new LineInternal("name" + i, "actual" + i);
            pojo.lines.add(internal);
        }
        String toJson = new Gson().toJson(pojo);
        System.out.println(toJson);
        LinePojo linePojo = new Gson().fromJson(toJson, LinePojo.class);
        for (LineInternal line : linePojo.lines) {
            System.out.println(line.actual + " " +line.name);
        }
    }
}
